package com.dwxt.cdms.controller.wx;

import com.alibaba.fastjson.JSONObject;
import com.dwxt.cdms.service.wx.MenuService;
import com.dwxt.cdms.util.wx.WxUtil;
import com.dwxt.common.base.BaseResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RequestMapping("/cdms/wx")
@RestController
public class WxController {


    @RequestMapping("/getMenu")
    public BaseResult page() {
        try {
            String accessToken = WxUtil.getAccessToken();
            JSONObject menu = MenuService.getMenu(accessToken);
            return BaseResult.ok(menu);
        } catch (Exception e) {
            return BaseResult.ok();
        }
    }
    @PostMapping("/createMenu")
    public BaseResult createMenu(@RequestBody JSONObject menu) {
        try {
            String accessToken = WxUtil.getAccessToken();
            MenuService.createMenu(menu,accessToken);
            return BaseResult.ok();
        } catch (Exception e) {
            return BaseResult.ok();
        }
    }


}

